package com.ruoyi.app.controller

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.PageData
import com.ruoyi.app.domain.dto.UserRecordDto
import com.ruoyi.app.domain.vo.UserRecordVo
import com.ruoyi.app.service.RecordApiService
import com.ruoyi.common.core.page.PageDomain
import io.swagger.annotations.Api
import io.swagger.annotations.ApiImplicitParam
import io.swagger.annotations.ApiImplicitParams
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("api/userRecord")
@Api(tags = ["我的记录相关接口"])
class RecordApiController {

    @Autowired
    private lateinit var recordApiService: RecordApiService


    @ApiOperation("获取用户记录列表")
    @GetMapping("getUserRecordList")
    fun getUserRecordList(pageDomain: PageDomain) : PageData<UserRecordVo> = recordApiService.getUserRecordList(pageDomain)

    @ApiOperation("保存用户记录")
    @PostMapping("addUserRecord")
    fun addUserRecord(userRecordDto: UserRecordDto): Data<Boolean> = recordApiService.addUserRecord(userRecordDto)

    @ApiOperation("批量移除用户记录")
    @GetMapping("removeUserRecord/{ids}")
    @ApiImplicitParams(
        ApiImplicitParam(
            name = "ids",
            value = "多个id使用逗号隔开",
            type = "path",
            required = true
        )
    )
    fun removeUserRecord(@PathVariable ids: String): Data<Boolean> = recordApiService.removeUserRecord(ids)
}